#!user/bin/env python3
# -- coding: utf-8 --
# @Createtime：2023/9/8 17:50
# @Updatetime：17:50
# @Author：Test008
# @File：7-封装
# @Description：
"""
面向对象中的私有成员变量和私有成员方法
"""


# class Phone:
#     # __current_voltage = None
#     # # __current_voltage = 1
#     __current_voltage = 0.5
#
#     def __keep_single_core(self):
#         print("让CPU以单核模式运行")
#
#     # 类中的其他成员使用self可以调用私有成员变量和私有成员方法
#     def call_by_5g(self):
#         if self.__current_voltage >= 1:
#             print("5g通话已经开启")
#         else:
#             self.__keep_single_core()
#             print("电量不足，无法使用5g，并已设置为单核运行模式进行省电")


# phone = Phone()
# 调用对象的私有成员变量会报错
# 调用对象的私有成员方法会报错
# print(phone.__current_voltage)
# phone.__keep_single_core()

# phone.call_by_5g()

class Phone:
    IMEI = None
    producer = None

    __current_voltage = 29  # 当前电压

    def call_by_5g(self):
        if self.__current_voltage > 30:
            print("5g通话已经开启")
        else:
            self.__keep_single_core()
            print("电量不足，无法使用5G通话，并设置为单核运行模式进行省电")

    def __keep_single_core(self):
        # print("让cpu以单核模式运行以节省电量")
        pass


phone = Phone()
phone.IMEI = "003032"
phone.producer = "小米"
# phone.__current_voltage = 33
# print(phone.__current_voltage)
# print(phone.__keep_single_core)
phone.call_by_5g()